home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / msysjour / vol03 / 05 / filter / ext.h < prev    next >
C/C++ Source or Header  |  1988-08-10  |  15KB  |  404 lines

  1. /*** ext.h - extension definitions
  2. *
  3. *   Copyright <C> 1988, Microsoft Corporation
  4. *
  5. * Purpose:
  6. *
  7. * NOTES:
  8. *
  9. *   1) THIS FILE IS SHIPPED WITH THE PRODUCT. This note, the file history and
  10. *      all code within "#ifdef EDITOR" conditionals should be REMOVED before
  11. *      shipping.
  12. *
  13. *      ALSO: be VERY carefull what gets put into this file. Technically, if it
  14. *      is NOT required for extension writers, it does NOT belong here.
  15. *
  16. *   2) Certain sections of this file should be removed for delivery with
  17. *      version 1.01.
  18. *
  19. * Revision History:
  20. *
  21. *   16-Jan-1987 mz  Add pascal typing
  22. *            Exportable switch lists
  23. *   10-Feb-1987 mz  Add fExecute
  24. *   22-Oct-1987 mz  Correct definitions as headers
  25. *   23-Oct-1987 bw  long LINE
  26. *   15-Dec-1987 bw  Add ReadCmd and ReadChar
  27. *            Add KbHook and KbUnHook
  28. *            Add toPIF() macro
  29. *   02-Mar-1988 ln  Add Falloc, Fdalloc, mgetenv, GetEditorObject
  30. *            Add _loadds & _export attribute
  31. *   16-Mar-1988 ln  Add event code
  32. *   25-Mar-1988 ln  Change kbhook/unhook to pre/postspawn
  33. *   28-Apr-1988 ln  Add color interfaces.
  34. *   12-May-1988 ln  Add menu interfaces & definitions.
  35. *   01-Jun-1988 ln  V101 changes
  36. *   21-Jun-1988 ln  Remove V101 changes, as extensions will get everything
  37. *            Update documentation & order. Removed buffer def.
  38. *   07-Jul-1988 ln  Changes for inclusion in the editor itself.
  39. *   14-Jul-1988 ln  Add rn struct
  40. *   26-Jul-1988 bw  CW: KeyData structure
  41. *   01-Aug-1988 ln  Restored buffer def
  42. *
  43. *************************************************************************/
  44.  
  45. /*************************************************************************
  46.  *
  47.  *  Macro Definitions
  48.  *
  49.  * BUFLEN is the maximum line length that can be passed or will be returned
  50.  * by the editor.
  51.  */
  52. #define BUFLEN    251
  53. /*
  54.  * EXPORT defines the attributes required for extension functions. _loadds
  55.  * is used such that extensions can be compiled /Aw as well as /Au.
  56.  */
  57. #define EXPORT        _loadds far
  58. #ifdef EDITOR
  59. #define EXTERNAL    far
  60. #else
  61. #define EXTERNAL    _loadds far
  62. #endif
  63. /*
  64.  * RQ_... are various request types supported for Get/Set EditorObject
  65.  */
  66. #define RQ_FILE     0x1000        /* GetEditorObject: File request*/
  67. #define RQ_FILE_HANDLE    0x1000        /*    File Handle        */
  68. #define RQ_FILE_NAME    0x1100        /*    ASCIIZ filename     */
  69. #define RQ_FILE_FLAGS    0x1200        /*    flags            */
  70. #define RQ_WIN        0x2000        /* Window request        */
  71. #define RQ_WIN_HANDLE    0x2000        /*    Window Handle        */
  72. #define RQ_WIN_CONTENTS 0x2100        /*    Window Contents     */
  73. #define RQ_WIN_CUR    0x2200        /*    Current Window Index    */
  74. #define RQ_COLOR    0x9000        /* Color request        */
  75. #define RQ_CLIP     0xf000        /* clipboard type        */
  76.  
  77. /*
  78.  * toPif is used when placing numeric or boolean switches in the swiDesc table
  79.  * to eliminate C 5.X compiler warnings.
  80.  *
  81.  * For example: { "Switchname", toPIF(switchvar), SWI_BOOLEAN },
  82.  */
  83. #define toPIF(x)  (PIF)(long)(void far *)&x
  84. /*
  85.  * Editor color table endicies. (Colors 25-35 are unassigned and available for
  86.  * extension use).
  87.  */
  88. #define FGCOLOR     20        /* foreground (normal) color    */
  89. #define HGCOLOR     21        /* highlighted region color    */
  90. #define INFCOLOR    22        /* information color        */
  91. #define ERRCOLOR    23        /* error message color        */
  92. #define STACOLOR    24        /* status line color        */
  93.  
  94. /*************************************************************************
  95.  *
  96.  *  General type Definitions
  97.  */
  98. typedef char flagType;            /* Boolean value        */
  99. typedef int  COL;            /* column or position with line */
  100. typedef long LINE;            /* line number within file    */
  101. #ifndef EDITOR
  102. typedef unsigned PFILE;         /* editor file handle        */
  103. typedef unsigned PWIN;            /* editor window handle     */
  104. #endif
  105.  
  106. typedef char buffer[BUFLEN];        /* line buffer            */
  107.  
  108. typedef struct {            /* file location        */
  109.     LINE    lin;            /* - line number        */
  110.     COL     col;            /* - column            */
  111.     } fl;
  112.  
  113. typedef struct {            /* screen location        */
  114.     int     lin;            /* - line number        */
  115.     int     col;            /* - column            */
  116.     } sl;
  117.  
  118. typedef struct {            /* file range            */
  119.     fl        flFirst;            /* - Lower line, or leftmost col*/
  120.     fl        flLast;            /* - Higher, or rightmost    */
  121.     } rn;
  122.  
  123. struct lineAttr {            /* Line color attribute info    */
  124.     unsigned char attr;         /* - Attribute of piece     */
  125.     unsigned char len;            /* - Bytes in colored piece    */
  126.     };
  127.  
  128. /*************************************************************************
  129.  *
  130.  * Function definition table definitions
  131.  */
  132. #if 0 /* defined(CW) UNDONE: this needs to be resolved! */
  133. typedef unsigned long CMDDATA;
  134. #else
  135. typedef unsigned CMDDATA;
  136. #endif
  137.  
  138. struct cmdDesc {            /* function definition entry    */
  139.     char far *name;            /* - pointer to name of fcn    */
  140.     flagType (pascal EXTERNAL *func)(); /* - pointer to function    */
  141.     CMDDATA  arg;            /* - used internally by editor    */
  142.     unsigned argType;            /* - user args allowed        */
  143.     };
  144. typedef struct cmdDesc far *PCMD;
  145.  
  146. #ifdef EDITOR
  147.                     /* CW Key info structure    */
  148. typedef struct KeyData {        /* Key information        */
  149.     unsigned ascii;            /* ASCII code, or .vkey if none */
  150.     unsigned scan;            /* scan code            */
  151.     unsigned vkey;            /* CW virtual key code        */
  152.     unsigned shift;            /* Shift state 0 - 3        */
  153.     PCMD pFunc;             /* command key will invoke    */
  154.     char name[30];            /* full name for key        */
  155.     } KeyData;
  156.  
  157. typedef unsigned KeyHandle;
  158. #endif
  159.  
  160. #define NOARG        0x0001        /* no argument specified    */
  161. #define TEXTARG     0x0002        /* text specified        */
  162. #define NULLARG     0x0004        /* arg + no cursor movement    */
  163. #define NULLEOL     0x0008        /* null arg => text from arg->eol*/
  164. #define NULLEOW     0x0010        /* null arg => text from arg->end word*/
  165. #define LINEARG     0x0020        /* range of entire lines    */
  166. #define STREAMARG   0x0040        /* from low-to-high, viewed 1-D */
  167. #define BOXARG        0x0080        /* box delimited by arg, cursor */
  168.  
  169. #define NUMARG        0x0100        /* text => delta to y position    */
  170. #define MARKARG     0x0200        /* text => mark at end of arg    */
  171.  
  172. #define BOXSTR        0x0400        /* single-line box => text    */
  173.  
  174. #define MODIFIES    0x1000        /* modifies file        */
  175. #define KEEPMETA    0x2000        /* do not eat meta flag     */
  176. #define WINDOWFUNC  0x4000        /* moves window         */
  177. #define CURSORFUNC  0x8000        /* moves cursor         */
  178.  
  179. /*************************************************************************
  180.  *
  181.  * Switch definition table defintions
  182.  */
  183. typedef flagType (pascal EXTERNAL *PIF)(char far *);
  184.  
  185. union swiAct {                /* switch location or routine    */
  186.     flagType (pascal EXTERNAL *pFunc)(char far *); /* - routine for text*/
  187.     int far *ival;            /* - integer value for NUMERIC    */
  188.     flagType far *fval;         /* - flag value for BOOLEAN    */
  189.     };
  190.  
  191. struct swiDesc {            /* switch definition entry    */
  192.     char far *name;            /* - pointer to name of switch    */
  193.     union swiAct act;            /* - pointer to value or fcn    */
  194.     int type;                /* - flags defining switch type */
  195.     };
  196. typedef struct swiDesc far *PSWI;
  197.  
  198. #define SWI_BOOLEAN 0            /* Boolean switch        */
  199. #define SWI_NUMERIC 1            /* hex or decimal switch    */
  200. #define SWI_SCREEN  4            /* switch affects screen    */
  201. #define SWI_SPECIAL 5            /* textual switch        */
  202. #define RADIX10 (0x0A << 8)        /* numeric switch is decimal    */
  203. #define RADIX16 (0x10 << 8)        /* numeric switch is hex    */
  204.  
  205. /*************************************************************************
  206.  *
  207.  * Argument defininition structures.
  208.  *
  209.  * We define a structure for each of the argument types that may be passed to
  210.  * an extension function. Then, we define the structure argType which is
  211.  * used to pass these arguments around in a union.
  212.  */
  213. struct    noargType {            /* no argument specified    */
  214.     LINE    y;                /* - cursor line        */
  215.     COL     x;                /* - cursor column        */
  216.     };
  217.  
  218. struct textargType {            /* text argument specified    */
  219.     int     cArg;            /* - count of <arg>s pressed    */
  220.     LINE    y;                /* - cursor line        */
  221.     COL     x;                /* - cursor column        */
  222.     char far *pText;            /* - ptr to text of arg     */
  223.     };
  224.  
  225. struct    nullargType {            /* null argument specified    */
  226.     int     cArg;            /* - count of <arg>s pressed    */
  227.     LINE    y;                /* - cursor line        */
  228.     COL     x;                /* - cursor column        */
  229.     };
  230.  
  231. struct lineargType {            /* line argument specified    */
  232.     int     cArg;            /* - count of <arg>s pressed    */
  233.     LINE yStart;            /* - starting line of range    */
  234.     LINE yEnd;                /* - ending line of range    */
  235.     };
  236.  
  237. struct streamargType {            /* stream argument specified    */
  238.     int     cArg;            /* - count of <arg>s pressed    */
  239.     LINE yStart;            /* - starting line of region    */
  240.     COL  xStart;            /* - starting column of region    */
  241.     LINE yEnd;                /* - ending line of region    */
  242.     COL  xEnd;                /* - ending column of region    */
  243.     };
  244.  
  245. struct boxargType {            /* box argument specified    */
  246.     int     cArg;            /* - count of <arg>s pressed    */
  247.     LINE yTop;                /* - top line of box        */
  248.     LINE yBottom;            /* - bottom line of bix     */
  249.     COL  xLeft;             /* - left column of box     */
  250.     COL  xRight;            /* - right column of box    */
  251.     };
  252.  
  253. struct    argType {
  254.     int     argType;
  255.     union   {
  256.     struct    noargType    noarg;
  257.     struct    textargType    textarg;
  258.     struct    nullargType    nullarg;
  259.     struct    lineargType    linearg;
  260.     struct    streamargType    streamarg;
  261.     struct    boxargType    boxarg;
  262.     } arg;
  263.     };
  264. typedef struct argType ARG;
  265.  
  266. /*************************************************************************
  267.  *
  268.  * Get/Set EditorObject data structures
  269.  */
  270. typedef struct {            /* define window contents    */
  271.     PFILE    pFile;            /* - handle of file displayed    */
  272.     sl        slMac;            /* - on-screen limits of window */
  273.     sl        slPos;            /* - position of upper left    */
  274.     fl        flPos;            /* - upper left corner wrt file */
  275.     } winContents;
  276. /*
  277.  * FILE flags values
  278.  */
  279. #define DIRTY        0x01        /* file had been modified    */
  280. #define FAKE        0x02        /* file is a pseudo file    */
  281. #define REAL        0x04        /* file has been read from disk */
  282. #define DOSFILE     0x08        /* file has CR-LF        */
  283. #define TEMP        0x10        /* file is a temp file        */
  284. #define NEW        0x20        /* file has been created by editor*/
  285. #define REFRESH     0x40        /* file needs to be refreshed    */
  286. #define READONLY    0x80        /* file may not be editted    */
  287.  
  288. #define DISKRO        0x0100        /* file on disk is read only    */
  289.  
  290. /*************************************************************************
  291.  *
  292.  * Event processing definitions
  293.  */
  294. typedef union {             /* arguments to event dispatches*/
  295.     unsigned int key;            /* - key for key events     */
  296.     PFILE    pfile;            /* file handle for file events    */
  297.     } EVTargs;
  298.  
  299. struct eventType {            /* event definition struct    */
  300.     unsigned    evtType;        /* - type            */
  301.     flagType (pascal EXPORT *func)(EVTargs);    /* - handler        */
  302.     struct eventType far *pEVTNext;    /* - next handler in list    */
  303.     PFILE    focus;            /* - applicable focus        */
  304.     EVTargs    arg;            /* - applicable agruments    */
  305.     };
  306. typedef struct eventType EVT;
  307.  
  308. #define EVT_RAWKEY    1        /* ALL keystrokes        */
  309. #define EVT_KEY     2        /* Editting keystrokes        */
  310. #define EVT_GETFOCUS    3        /* file GETs focus.        */
  311. #define EVT_LOOSEFOCUS    4        /* file looses focus.        */
  312. #define EVT_EXIT    5        /* about to exit.        */
  313. #define EVT_SHELL    6        /* about to sell or compile    */
  314. #define EVT_UNLOAD    7        /* about to be unloaded.    */
  315. #define EVT_IDLE    8        /* idle event            */
  316. #define EVT_CANCEL    9        /* do-nothing cancel        */
  317. #define EVT_REFRESH    10        /* about to refresh a file    */
  318. /*
  319. ** Events handled through OTHER interfaces.
  320. */
  321. #define EVT_MENU    100        /* menu about to be viewed    */
  322. #define EVT_MENUSELECT    101        /* menu selected        */
  323.  
  324. /*************************************************************************
  325.  *
  326.  * CW Menu, window and dialog definitions
  327.  *
  328.  * action constants for ChangeMenu
  329.  */
  330. #define MNU_DISABLE    1        /* disable (grey) menu item    */
  331. #define MNU_ENABLE    2        /* enable menu item        */
  332. #define MNU_DELETE    3        /* delete menu item        */
  333. #define MNU_RENAME    4        /* rename menu item        */
  334. #define MNU_ACCEL    5        /* define menu item accelerator */
  335. /*
  336.  * Message box types.
  337.  */
  338. #define MBOX_OK         1    /* <OK>             */
  339. #define MBOX_YESNOCANCEL    2    /* <YES> <NO> <CANCEL>        */
  340. #define MBOX_RETRYCANCEL    3    /* <RETRY> <CANCEL>        */
  341. #define MBOX_OKCANCEL        4    /* <OK> <CANCEL>        */
  342. #define MBOX_ABORT        5    /* <ABORT>            */
  343. #define MBOX_YESNO        6    /* <YES> <NO>            */
  344. #define MBOX_RETRY        7    /* <RETRY>            */
  345. #define MBOX_TYPE        0x0f    /* message type         */
  346. #define MBOX_BEEP        0x10    /* beep when displayed        */
  347. #define MBOX_CAPTION        0x20    /* 1st param is caption     */
  348.  
  349. /*************************************************************************
  350.  *
  351.  * Editor lowlevel function prototypes.
  352.  *
  353.  * This list defines the routines within the editor which may be called
  354.  * by extension functions.
  355.  */
  356. #ifndef EDITOR
  357. flagType    pascal Replace        (char, COL, LINE, PFILE, flagType);
  358. void        pascal MoveCur        (COL, LINE);
  359. void        pascal DelLine        (PFILE, LINE, LINE);
  360. void        pascal DelBox        (PFILE, COL, LINE, COL, LINE);
  361. void        pascal DelStream        (PFILE, COL, LINE, COL, LINE);
  362. PFILE        pascal AddFile        (char far *);
  363. void        pascal DelFile        (PFILE);
  364. flagType    pascal RemoveFile        (PFILE);
  365. void        pascal CopyBox        (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  366. void        pascal CopyLine        (PFILE, PFILE, LINE, LINE, LINE);
  367. void        pascal CopyStream        (PFILE, PFILE, COL, LINE, COL, LINE, COL, LINE);
  368. void        pascal pFileToTop        (PFILE);
  369. void        pascal Display        (void);
  370. void        pascal GetCursor        (COL far *, LINE far *);
  371. LINE        pascal FileLength        (PFILE);
  372. int        pascal GetLine        (LINE, char far *, PFILE);
  373. PFILE        pascal FileNameToHandle (char far *, char far *);
  374. flagType    pascal FileRead        (char far *, PFILE);
  375. flagType    pascal FileWrite        (char far *, PFILE);
  376. flagType    pascal SetKey        (char far *, char far *);
  377. int        pascal DoMessage        (char far *);
  378. void        pascal PutLine        (LINE, char far *, PFILE);
  379. flagType    pascal BadArg        (void);
  380. flagType    pascal fExecute        (char far *);
  381. PCMD        pascal ReadCmd        (void);
  382. long        pascal ReadChar        (void);
  383. void        pascal KbHook        (void);
  384. void        pascal KbUnHook        (void);
  385. char far *  pascal Falloc        (long);
  386. void        pascal Fdalloc        (char far *);
  387. char far *  pascal mgetenv        (char far *);
  388. flagType    pascal GetEditorObject  (unsigned, unsigned, void far *);
  389. flagType    pascal SetEditorObject  (unsigned, unsigned, void far *);
  390. flagType    pascal DeclareEvent     (unsigned, EVTargs);
  391. void        pascal RegisterEvent    (EVT *);
  392. void        pascal DeRegisterEvent  (EVT *);
  393. PSWI        pascal FindSwitch        (char far *);
  394. int        pascal search        (PFILE, flagType, flagType, char far *, COL far *, LINE far *);
  395. int        pascal REsearch        (PFILE, flagType, flagType, char far *, COL far *, LINE far *);
  396. char far *  pascal NameToKeys        (char far *, char far *);
  397. flagType    pascal GetColor        (LINE, struct lineAttr far *, PFILE);
  398. void        pascal PutColor        (LINE, struct lineAttr far *, PFILE);
  399. int        pascal AddMenu        (char far *, char far *, void (pascal EXPORT *)(), flagType);
  400. int        pascal AddMenuItem        (int, char far *, char far *);
  401. flagType    pascal ChangeMenu        (int, int, char far *);
  402. int        pascal MessageBox        (char far *, char far *, char far *, int);
  403. #endif
  404.